home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / ab20 / unarced / utilities / shells / sksh / scr_source / man.s < prev    next >
Text File  |  1995-03-17  |  1KB  |  41 lines

  1. #!c:sksh
  2.  
  3. #*************************************************************************
  4. # This is a "man" function which can be used to retrieve documentation
  5. # files stored in a MAN: directory.  These files (which are often
  6. # included with public domain software as "readme" files) should be
  7. # copied to a name such as "MAN:prog.MAN".  Then, "man prog" can be used
  8. # to retrieve the files with the $PAGER command.
  9. #*************************************************************************
  10.  
  11.    local _fspec _loc _path
  12.  
  13.    [ -m 'MAN:' ] ||
  14.       echo "MAN: must be assigned to a directory containing manpages." &&
  15.       return 1
  16.  
  17.    if [ "$#" -ne 1 -o "$1" = '-?' ]
  18.    then
  19.       echo 'Usage:' $(basename $0) 'man-entry'
  20.       echo '       (Displays man page entries from the MAN: directory'
  21.       echo '        or any directory in $MANPATH)'
  22.       return 1
  23.    fi
  24.  
  25.    _fspec=''
  26.  
  27.    _path="${MANPATH:-MAN:,MAN:SKsh}"
  28.  
  29.    while [ -n "$_path" -a -z "$_fspec" ]
  30.    do
  31.       _loc=$(tackon $(car "$_path" ',') "$1")
  32.       _path=$(cdr "$_path" ',')
  33.       [ -f "$_loc.MAN" ]                 && _fspec="$_loc.MAN"
  34.       [ -z "$_fspec" -a -f "$_loc.doc" ] && _fspec="$_loc.doc"
  35.       [ -z "$_fspec" -a -f "$_loc.txt" ] && _fspec="$_loc.txt"
  36.    done
  37.  
  38.    [ -z "$_fspec" ] && echo "No manual entry for $1" && return 1
  39.  
  40.    ${PAGER:-more} "$_fspec"
  41.